
function useLoadingMessage(message) {
	var loadingMessage;
	if (message) {
		loadingMessage = message;
	} else {
		loadingMessage = "Loading";
	}
	
	DWREngine.setPreHook(function () {
		var disabledZone = $("disabledZone");
		if (!disabledZone) {
			disabledZone = document.createElement("div");
			disabledZone.setAttribute("id", "disabledZone");
			disabledZone.style.position = "absolute";
			disabledZone.style.zIndex = "1000";
			disabledZone.style.left = "0px";
			disabledZone.style.top = "0px";
			disabledZone.style.width = "100%";
			disabledZone.style.height = "100%";
			document.body.appendChild(disabledZone);
			var messageZone = document.createElement("div");
			messageZone.setAttribute("id", "messageZone");
			messageZone.style.position = "absolute";
			messageZone.style.top = "100px";
			messageZone.style.left = "400px";
			messageZone.style.width = "200";
			messageZone.style.height = "50";
			messageZone.style.background = "green";
			messageZone.style.color = "white";
			messageZone.style.fontFamily = "Arial,Helvetica,sans-serif";
			messageZone.style.padding = "4px";
			disabledZone.appendChild(messageZone);
			var text = document.createTextNode(loadingMessage);
			messageZone.appendChild(text);
		} else {
			$("messageZone").innerHTML = loadingMessage;
			disabledZone.style.visibility = "visible";
		}
	});
	DWREngine.setPostHook(function () {
		$("disabledZone").style.visibility = "hidden";
	});
}
function init() {
	useLoadingMessage("\u6b63\u5728\u52a0\u8f7d\u6570\u636e\uff0c\u8bf7\u7a0d\u540e\u2026\u2026");
	DWREngine.setTimeout(5000);
}
function showAdd(obj, schoolname) {
	var hdObj = document.getElementById("hdObj");
	var hdObjid = document.getElementById("hdid");
	var addCov = document.getElementById("addCov");
	//当类型改变的时候,清空刚已经选择的值
	var hiddenCov = document.getElementById("hiddenCov");
    var hiddenCovName = document.getElementById("hiddenCovName");
    
    
   // alert("前："+hiddenCov.value);
    hiddenCov.value="";
    hiddenCovName.value="";
   // alert("后:"+hiddenCov.value);
    var lx=document.getElementById("checklb");
   // alert("类型：--"+lx.value);
	if (obj.value == 1) {
		hdObj.value = schoolname;
		hdObjid.value = addCov.innerHTML = "&nbsp;";
	}else {
		hdObj.value = "";
		hdObjid.value = "";
		addCov.innerHTML = "<a href='javascript:chechHdObj()'>\u9009\u62e9</a>";
	}
	  if(lx.value=="--选择活动类别--"||lx.value=="--选择荣誉类别--"||lx.value=="--选择处分类别--")
	{
	hdObjid.value = addCov.innerHTML = "&nbsp;";
	 }
}
function upAdd(obj, schoolname) {
	var hdObj = document.getElementById("hdObj");
	var addCov = document.getElementById("addCov");
	if (obj == 1) {

	//alert("234");
		hdObj.value = schoolname;
		addCov.innerHTML = "&nbsp;";
	} else {

		//hdObj.value = "";
		addCov.innerHTML = "<a href='javascript:chechHdObj()'>\u9009\u62e9</a>";
	}
}
function chechHdObj() {
	if(document.getElementById('bjhdnj')){
		document.getElementById('bjhdnj').getElementsByTagName('option')[0].selected='selected';
	}
	if(document.getElementById('jshdnj')){
		document.getElementById('jshdnj').getElementsByTagName('option')[0].selected='selected';
	}
	if(document.getElementById('jshdbj')){
		document.getElementById('jshdbj').getElementsByTagName('option')[0].selected='selected';
	}
	if(document.getElementById('xshdnj')){
		document.getElementById('xshdnj').getElementsByTagName('option')[0].selected='selected';
	}
	if(document.getElementById('xshdbj')){
		document.getElementById('xshdbj').getElementsByTagName('option')[0].selected='selected';
	}
	var bodyh = document.body.clientHeight;
	var bodyw = document.body.clientWidth;
	var conh = document.body.scrollHeight;
	var float_bg = document.getElementById("float_bg");
	var float_zz = document.getElementById("float_zz");
	var bakDiv = document.getElementById("hdCheck");
	var checklb = document.getElementById("checklb");
	var bjCov = document.getElementById("bjCov");
	var jsCov = document.getElementById("jsCov");
	var xsCov = document.getElementById("xsCov");
	float_bg.style.display = "block";
	float_bg.style.z_index = "30000";
	float_zz.style.display = "block";
	bakDiv.style.display = "block";
	if (checklb.value == "2") {
		bjCov.style.display = "";
		jsCov.style.display = "none";
		xsCov.style.display = "none";
	}
	if (checklb.value == "3") {
		bjCov.style.display = "none";
		jsCov.style.display = "";
		xsCov.style.display = "none";
	}
	if (checklb.value == "4") {
		bjCov.style.display = "none";
		jsCov.style.display = "none";
		xsCov.style.display = "";
	}
	float_bg.style.height = conh;
	float_zz.style.height = conh;
	var float_nrw = bakDiv.offsetWidth;
	var float_nrh = bakDiv.offsetHeight;
	bakDiv.style.left = (bodyw - float_nrw) / 2;
	bakDiv.style.top = (bodyh - float_nrh) / 2 + document.body.scrollTop;
}
function setHdObjvalue(obj) {
	//var hdC = document.getElementsByName(obj);
	var hdObj = document.getElementById("hdObj");
	var hdid = document.getElementById("hdid");
	//var hiddenCov = document.getElementById("hiddenCov");
   // var hiddenCovName = document.getElementById("hiddenCovName");
	hdid.value = document.getElementById("hiddenCov").value;
	hdObj.value = document.getElementById("hiddenCovName").value;

	//alert(hdC.length);
	//for (i = 0; i < hdC.length; i++) {
		///if (hdC[i].checked) {
			//hdid.value += hdC[i].value + ",";
			//hdObj.value += hdC[i].parentNode.parentNode.childNodes[1].innerHTML + ",";

			//alert(hdC[i].parentNode.parentNode.childNodes[1].tagName);
		//}
	//}
	var hiddenCovName = document.getElementById("hiddenCovName");
	
	//alert("活动对象1:"+hdObj.value);
	//alert("活动对象2:"+hiddenCovName.value);
	closelistDiv("hdCheck");
}

function getClassCheckBox() {
	var ty = document.getElementById("sign").value;
	var nj = document.getElementById("bjhdnj").value;
	var used = document.getElementById("hdid").value;
	//alert(nj+"-----"+used);
	if ("add" == ty) {  // alert("添加!");
		zjglDwr.getClasslist(nj, bjCheckBox);
	} else {

	    // alert("修改!");
		zjglDwr.getClassL(nj, used, upbjCheckBox);
	}
}

//添加获得班级
function bjCheckBox(data) {
//alert("班级的个数："+data.length);
	var tb = document.getElementById("bjhd");
	var hdid = document.getElementById("hdid").value;
	
	var th = "<table width='100%' border='0' cellpadding='0' cellspacing='0'> ";
	var tbody = "";
	if (null != data && "" != data) {
		var list = "<tr>";
		for (i = 0; i < data.length; i++) {
			if ((i + 1) % 3 == 0) {
				list += "<td><table border='0' cellspacing='0' cellpadding='0'><tr><td><input name='cName' type='checkbox' onclick='setValueLy(this)' value='" + data[i].classId + "'" + "></td><td>" + data[i].bjmc + "</td></tr></table></td></tr>";
			} else {
				if (i == data.length - 1) {
					list += "<td><table border='0' cellspacing='0' cellpadding='0'><tr><td><input name='cName' type='checkbox' onclick='setValueLy(this)' value='" + data[i].classId+ "'" + "></td><td>" + data[i].bjmc + "</td></tr></table></td>";
					for (j = 0; j < 3 - data.length % 3; j++) {
						list += "<td><table border='0' cellspacing='0' cellpadding='0'><tr><td>&nbsp;</td></tr></table></td>";
					}
					list += "</tr>";
				} else {
					list += "<td><table border='0' cellspacing='0' cellpadding='0'><tr><td><input name='cName' type='checkbox' onclick='setValueLy(this)' value='" + data[i].classId + "'" + "></td><td>" + data[i].bjmc + "</td></tr></table></td>";
				}
			}
		}
		tbody = list;
	}
	tb.innerHTML = th + tbody;
	var hiddenCov = document.getElementById("hiddenCov").value;
	var obj = document.getElementsByName("cName");

	//alert(obj.length);
	var s = hiddenCov.split(",");
	for (i = 0; i < obj.length; i++) {
		for (j = 0; j < s.length-1; j++) {
			if (obj[i].value == s[j]) {
				obj[i].checked = true;
			}
		}
	}
	//alert("banj2");
}
function setValueLy(n) {
//alert("jiaoshi");
var hiddenCov = document.getElementById("hiddenCov");
var hiddenCovName = document.getElementById("hiddenCovName");

	//alert("隐藏域的值--前："+hiddenCovName.value);
	var s = hiddenCov.value.split(",");
	var names=hiddenCovName.value.split(",");
	var boo = false;

	//被选中的时候
	if (n.checked == true) {
		if (hiddenCov.value == "") {//隐藏域没有值时
			hiddenCov.value += n.value + ",";
			hiddenCovName.value+=n.parentNode.parentNode.childNodes[1].innerHTML + ",";
		} else {
		//隐藏域有值时，判断如果隐藏域没有该值就添加
			for(j=0; j<s.length-1; j++)
			{//有相等值的时候
			if(s[j]==n.value)
			{
			boo=true;
			}
			}
			if (boo== false) {//没有相等的时候，就加入隐藏域
			hiddenCov.value += n.value + ",";
			hiddenCovName.value+=n.parentNode.parentNode.childNodes[1].innerHTML + ",";
		              }
			}
	} else {//取消选中的时候
		for (j = 0; j < s.length - 1; j++) {
		   			if (n.value == s[j]) {
				s.splice(j, 1);
				names.splice(j, 1);
			}
		}
		for(j = 0; j < s.length ; j++){
			//hiddenCov.value = s[j] + ",";
		hiddenCov.value=s;
		hiddenCovName.value=names;
		}
		//hiddenCovName.value=names[j]+",";
	}

	//alert("隐藏域的值--后："+hiddenCov.value);
	//alert("隐藏域的值--后："+hiddenCovName.value);
}



//修改获得班级
function upbjCheckBox(data) {
   var hiddenCov = document.getElementById("hiddenCov");
   var s = hiddenCov.value.split(",");
   
  //alert("隐藏："+hiddenCov.value);
	var tb = document.getElementById("bjhd");
	var th = "<table width='100%' border='0' cellpadding='0' cellspacing='0'> ";
	var tbody = "";
	if (null != data && "" != data) {
		var list = "<tr>";
		for (i = 0; i < data.length; i++) {
		   var b=false;
		for(k=0;k<s.length-1;k++){
			if(data[i].bid==s[k])
			{
			b=true;
			}
	}
		if ((i + 1) % 3 == 0) {
			list += "<td><table border='0' cellspacing='0' cellpadding='0'><tr><td><input name='cName' type='checkbox' onclick='setValueLy(this)' value='" + data[i].bid;
				if ("y" == data[i].used && b==true) {
					list += "' checked = 'checked'></td><td>" + data[i].bname + "</td></tr></table></td></tr>";
				} else {
					list += "'></td><td>" + data[i].bname + "</td></tr></table></td></tr>";
				}
			} else {
				if (i == data.length - 1) {
					list += "<td><table border='0' cellspacing='0' cellpadding='0'><tr><td><input name='cName' type='checkbox' onclick='setValueLy(this)' value='" + data[i].bid;
					if ("y" == data[i].used &&b==true) {
						list += "' checked = 'checked'></td><td>" + data[i].bname + "</td></tr></table></td>";
					} else {
						list += "'></td><td>" + data[i].bname + "</td></tr></table></td>";
					}
					for (j = 0; j < 3 - data.length % 3; j++) {
						list += "<td><table border='0' cellspacing='0' cellpadding='0'><tr><td>&nbsp;</td></tr></table></td>";
					}
					list += "</tr>";
				} else {
					list += "<td><table border='0' cellspacing='0' cellpadding='0'><tr><td><input name='cName' type='checkbox' onclick='setValueLy(this)' value='" + data[i].bid;
					if ("y" == data[i].used &&b==true) {
						list += "' checked = 'checked'></td><td>" + data[i].bname + "</td></tr></table></td>";
					} else {
						list += "'></td><td>" + data[i].bname + "</td></tr></table></td>";
					}
				}
			}
		}
		tbody = list;
	}
	tb.innerHTML = th + tbody;
	
	//var hiddenCov = document.getElementById("hiddenCov").value;
	var obj = document.getElementsByName("cName");
	//alert(obj.length);
	var s = hiddenCov.value.split(",");
	for (i = 0; i < obj.length; i++) {
		for (j = 0; j < s.length-1; j++) {
			if (obj[i].value == s[j]) {
				obj[i].checked = true;
			}
		}
	}	
}
function getJshdBj() {
	var nj = document.getElementById("jshdnj").value;
	zjglDwr.getClass(nj, jshdBjSelectOption);
}
function jshdBjSelectOption(data) {
	DWRUtil.removeAllOptions("jshdbj");
	DWRUtil.addOptions("jshdbj", {"":"\u8bf7\u9009\u62e9\u73ed\u7ea7"});
	DWRUtil.addOptions("jshdbj", data);
}
function getJshdTeacherCheckBox() {
	var bj = document.getElementById("jshdbj").value;
	var ty = document.getElementById("sign").value;
	var used = document.getElementById("hdid").value;
	if ("add" == ty) {
		zjglDwr.getTeacher(bj, JshdTeacherCheckBox);
	} else {
		zjglDwr.getTeacherL(bj, used, upJshdTeacherCheckBox);
	}
}

//添加获得教师
function JshdTeacherCheckBox(data) {
   // alert(data.length);
	var tb = document.getElementById("jshd");
	var th = "<table width='100%' border='0' cellpadding='0' cellspacing='0'>";
	var tbody = "";
	if (null != data && "" != data) {
		var list = "<tr>";
		for (i = 0; i < data.length; i++) {
			if ((i + 1) % 5 == 0) {
				list += "<td><table border='0' cellspacing='0' cellpadding='0'><tr><td><input name='tName' type='checkbox' onclick='setValueLy(this)' value='" + data[i].userId + "'" + "></td><td>" + data[i].xm + "</td></tr></table></td></tr>";
			} else {
				if (i == data.length - 1) {
					list += "<td><table border='0' cellspacing='0' cellpadding='0'><tr><td><input name='tName' type='checkbox' onclick='setValueLy(this)'　value='" + data[i].userId + "'" + "></td><td>" + data[i].xm + "</td></tr></table></td>";
					for (j = 0; j < 5 - data.length % 5; j++) {
						list += "<td><table border='0' cellspacing='0' cellpadding='0'><tr><td>&nbsp</td><td>&nbsp</td></tr></table></td>";
					}
					list += "</tr>";
				} else {
			list += "<td><table border='0' cellspacing='0' cellpadding='0'><tr><td><input name='tName' type='checkbox' onclick='setValueLy(this)' value='" + data[i].userId + "'" + "></td><td>" + data[i].xm + "</td></tr></table></td>";
				}
			}
		}
		tbody = list;
	}
	tb.innerHTML = th + tbody;
	var hiddenCov = document.getElementById("hiddenCov").value;
	var obj = document.getElementsByName("tName");
	//alert(obj.length);
	var s = hiddenCov.split(",");
	for (i = 0; i < obj.length; i++) {
		for (j = 0; j < s.length-1; j++) {
			if (obj[i].value == s[j]) {
				obj[i].checked = true;
			}
		}
	}
	  // alert("教师2");
}

//修改获得教师
function upJshdTeacherCheckBox(data) {
	 var hiddenCov = document.getElementById("hiddenCov");
   var s = hiddenCov.value.split(",");
   	
	var tb = document.getElementById("jshd");
	var th = "<table width='100%' border='0' cellpadding='0' cellspacing='0'>";
	var tbody = "";
	if (null != data && "" != data) {
		var list = "<tr>";
		for (i = 0; i < data.length; i++) {
		 
		 var b=false;
		for(k=0;k<s.length-1;k++){
			if(data[i].tid==s[k])
			{
			b=true;
			}
	}
		
			if ((i + 1) % 5 == 0) {
				list += "<td><table border='0' cellspacing='0' cellpadding='0'><tr><td><input name='tName' type='checkbox' onclick='setValueLy(this)' value='" + data[i].tid;
				if ("y" == data[i].used && b==true) {
					list += "' checked = 'checked'></td><td>" + data[i].tname + "</td></tr></table></td></tr>";
				} else {
					list += "'></td><td>" + data[i].tname + "</td></tr></table></td></tr>";
				}
			} else {
				if (i == data.length - 1) {
					list += "<td><table border='0' cellspacing='0' cellpadding='0'><tr><td><input name='tName' type='checkbox' onclick='setValueLy(this)' value='" + data[i].tid;
					if ("y" == data[i].used && b==true) {
						list += "' checked = 'checked'></td><td>" + data[i].tname + "</td></tr></table></td>";
					} else {
						list += "'></td><td>" + data[i].tname + "</td></tr></table></td>";
					}
					for (j = 0; j < 5 - data.length % 5; j++) {
						list += "<td><table border='0' cellspacing='0' cellpadding='0'><tr><td>&nbsp;</td></tr></table></td>";
					}
					list += "</tr>";
				} else {
					list += "<td><table border='0' cellspacing='0' cellpadding='0'><tr><td><input name='tName' type='checkbox' onclick='setValueLy(this)' value='" + data[i].tid;
					if ("y" == data[i].used && b==true) {
						list += "' checked = 'checked'></td><td>" + data[i].tname + "</td></tr></table></td>";
					} else {
						list += "'></td><td>" + data[i].tname + "</td></tr></table></td>";
					}
				}
			}
		}
		tbody = list;
	}
	tb.innerHTML = th + tbody;
	//var hiddenCov = document.getElementById("hiddenCov").value;
	var obj = document.getElementsByName("tName");
	//alert(obj.length);
	var s = hiddenCov.value.split(",");
	for (i = 0; i < obj.length; i++) {
		for (j = 0; j < s.length-1; j++) {
			if (obj[i].value == s[j]) {
				obj[i].checked = true;
			}
		}
	}
}
function getxhdBj() {
	var nj = document.getElementById("xshdnj").value;
	zjglDwr.getClass(nj, xshdBjSelectOption);
}
function xshdBjSelectOption(data) {
	DWRUtil.removeAllOptions("xshdbj");
	DWRUtil.addOptions("xshdbj", {"":"\u8bf7\u9009\u62e9\u73ed\u7ea7"});
	DWRUtil.addOptions("xshdbj", data);
}
function getXshdStu() {
	var bj = document.getElementById("xshdbj").value;
	var ty = document.getElementById("sign").value;
	var used = document.getElementById("hdid").value;
	if ("add" == ty) {
		zjglDwr.getStudent(bj, xshdStuCheckBox);
	} else {
		zjglDwr.getStudentL(bj, used, upxshdStuCheckBox);
	}
}

//添加获得学生
function xshdStuCheckBox(data) {
//alert("xues");
	var tb = document.getElementById("xshd");
	var th = "<table width='100%' border='0' cellpadding='0' cellspacing='0'>";
	var tbody = "";
	if (null != data && "" != data) {
		var list = "<tr>";
		for (i = 0; i < data.length; i++) {
			if ((i + 1) % 5 == 0) {
				list += "<td><table border='0' cellspacing='0' cellpadding='0'><tr><td><input name='sName' type='checkbox' onclick='setValueLy(this)' value='" + data[i].userId + "'" + "></td><td>" + data[i].xm + "</td></tr></table></td></tr>";
			} else {
				if (i == data.length - 1) {
					list += "<td><table border='0' cellspacing='0' cellpadding='0'><tr><td><input name='sName' type='checkbox' onclick='setValueLy(this)' value='" + data[i].userId + "'" + "></td><td>" + data[i].xm + "</td></tr></table></td>";
					for (j = 0; j < 5 - data.length % 5; j++) {
						list += "<td><table border='0' cellspacing='0' cellpadding='0'><tr><td>&nbsp</td><td>&nbsp</td></tr></table></td>";
					}
					list += "</tr>";
				} else {
					list += "<td><table border='0' cellspacing='0' cellpadding='0'><tr><td><input name='sName' type='checkbox' onclick='setValueLy(this)' value='" + data[i].userId + "'" + "></td><td>" + data[i].xm + "</td></tr></table></td>";
				}
			}
		}
		tbody = list;
	}
	tb.innerHTML = th + tbody;
	var hiddenCov = document.getElementById("hiddenCov").value;
	var obj = document.getElementsByName("sName");
	//alert(obj.length);
	var s = hiddenCov.split(",");
	for (i = 0; i < obj.length; i++) {
		for (j = 0; j < s.length-1; j++) {
			if (obj[i].value == s[j]) {
				obj[i].checked = true;
			}
		}
	}
}

//修改获得学生
function upxshdStuCheckBox(data) {
  var hiddenCov = document.getElementById("hiddenCov");
   var s = hiddenCov.value.split(",");
  
  var tb = document.getElementById("xshd");
	var th = "<table width='100%' border='0' cellpadding='0' cellspacing='0'>";
	var tbody = "";
	if (null != data && "" != data) {
		var list = "<tr>";
		for (i = 0; i < data.length; i++) {
		
		 var b=false;
		for(k=0;k<s.length-1;k++){
			if(data[i].sid==s[k])
			{
			b=true;
			}
	}
		
			if ((i + 1) % 5 == 0) {
				list += "<td><table border='0' cellspacing='0' cellpadding='0'><tr><td><input name='sName' type='checkbox' onclick='setValueLy(this)' value='" + data[i].sid;
				if ("y" == data[i].used&& b==true) {
					list += "' checked = 'checked'></td><td>" + data[i].sName + "</td></tr></table></td></tr>";
				} else {
					list += "'></td><td>" + data[i].sName + "</td></tr></table></td></tr>";
				}
			} else {
				if (i == data.length - 1) {
					list += "<td><table border='0' cellspacing='0' cellpadding='0'><tr><td><input name='sName' type='checkbox' onclick='setValueLy(this)' value='" + data[i].sid;
					if ("y" == data[i].used&& b==true) {
						list += "' checked = 'checked'></td><td>" + data[i].sName + "</td></tr></table></td>";
					} else {
						list += "'></td><td>" + data[i].sName + "</td></tr></table></td>";
					}
					for (j = 0; j < 5 - data.length % 5; j++) {
						list += "<td><table border='0' cellspacing='0' cellpadding='0'><tr><td>&nbsp;</td></tr></table></td>";
					}
					list += "</tr>";
				} else {
					list += "<td><table border='0' cellspacing='0' cellpadding='0'><tr><td><input name='sName' type='checkbox' onclick='setValueLy(this)' value='" + data[i].sid;
					if ("y" == data[i].used&& b==true) {
						list += "' checked = 'checked'></td><td>" + data[i].sName + "</td></tr></table></td>";
					} else {
						list += "'></td><td>" + data[i].sName + "</td></tr></table></td>";
					}
				}
			}
		}
		tbody = list;
	}
	tb.innerHTML = th + tbody;
	
	//var hiddenCov = document.getElementById("hiddenCov").value;
	var obj = document.getElementsByName("sName");
	//alert(obj.length);
	var s = hiddenCov.value.split(",");
	for (i = 0; i < obj.length; i++) {
		for (j = 0; j < s.length-1; j++) {
			if (obj[i].value == s[j]) {
				obj[i].checked = true;
			}
		}
	}
	
}
function getCfdjSelect() {
	var lb = document.getElementById("checklb").value;
	if (null != lb && "" != lb) {
		zjglDwr.getcfdj(lb, cfdjSelectOption);
	}
}
function cfdjSelectOption(data) {
	DWRUtil.removeAllOptions("cfdj");
	DWRUtil.addOptions("cfdj", {"":"\u9009\u62e9\u5904\u5206\u7b49\u7ea7"});
	DWRUtil.addOptions("cfdj", data);
}

